//
//  GWCommentCell.m
//  百思不得姐
//
//  Created by qianfeng on 16/3/7.
//  Copyright © 2016年 高炜. All rights reserved.
//

#import "GWCommentCell.h"
#import "GWComment.h"
#import "GWUser.h"
#import <UIImageView+WebCache.h>
@interface GWCommentCell ()
@property (weak, nonatomic) IBOutlet UIImageView *headerView;
@property (weak, nonatomic) IBOutlet UIImageView *sexView;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *conentLabel;
@property (weak, nonatomic) IBOutlet UILabel *likeCountLabel;
@property (weak, nonatomic) IBOutlet UIButton *voiceButtom;

@end
@implementation GWCommentCell
-(BOOL)canBecomeFirstResponder
{
    return YES;
}
-(BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    return NO;
}
- (void)awakeFromNib {
    UIImageView *imageView =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"mainCellBackground"]];
    self.backgroundView =imageView;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)setComment:(GWComment *)comment
{

    _comment =comment;
    [self.headerView showHeaderViewWithIcon:comment.user.profile_image];
   
    self.sexView.image = [comment.user.sex isEqualToString:GWUserSexM]?[UIImage imageNamed:@"Profile_manIcon"]:[UIImage imageNamed:@"Profile_womanIcon"];
    self.titleLabel.text =comment.user.username;
    self.conentLabel.text =comment.content;
    self.likeCountLabel.text =[NSString stringWithFormat:@"%ld",comment.like_count];
    if (comment.voiceuri.length) {
        self.voiceButtom.hidden =NO;
        [self.voiceButtom setTitle:[NSString stringWithFormat:@"%ld''",comment.voicetime] forState:UIControlStateNormal];
    }
    else
    {
        self.voiceButtom.hidden =YES;
    }
}
-(void)setFrame:(CGRect)frame
{
    frame.origin.x =GWEssencCellMargin;
    frame.size.width -=GWEssencCellMargin*2;
    [super setFrame:frame];
}
@end
